package com.fyy.im.message;

import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author fyy
 * @Description
 * @Date 2021/5/11 10:23
 */
@Data
public abstract class Message implements Serializable {

    public static Class<?> getMessageClass(int messageType){
        return messageClasses.get(messageType);
    }
    private int sequenceId;
    private int messageType;
    public abstract int getMessageType();

    public static final int LoginRequestMessage = 0;
    public static final int LoginResponseMessage = 1;
    public static final int ChatRequestMessage = 2;
    public static final int ChatResponseMessage = 3;
    public static final int GCRequestMessage = 4;
    public static final int GCResponseMessage = 5;
    public static final int GJRequestMessage = 6;
    public static final int GJResponseMessage = 7;
    public static final int GQRequestMessage = 8;
    public static final int GQResponseMessage = 9;
    public static final int GChatRequestMessage = 10;
    public static final int GChatResponseMessage = 11;
    public static final int GMRequestMessage = 12;
    public static final int GMResponseMessage = 13;
    public static final int PingMessage = 14;
    private static final Map<Integer,Class<?>> messageClasses = new HashMap<>();

    static {
        messageClasses.put(LoginRequestMessage,LoginRequestMessage.class);
        messageClasses.put(LoginResponseMessage,LoginResponseMessage.class);
        messageClasses.put(ChatRequestMessage,ChatRequestMessage.class);
        messageClasses.put(ChatResponseMessage,ChatResponseMessage.class);
        messageClasses.put(GCRequestMessage,GCRequestMessage.class);
        messageClasses.put(GCResponseMessage,GCResponseMessage.class);
        messageClasses.put(GJRequestMessage,GJRequestMessage.class);
        messageClasses.put(GJResponseMessage,GJResponseMessage.class);
        messageClasses.put(GQRequestMessage,GQRequestMessage.class);
        messageClasses.put(GQResponseMessage,GQResponseMessage.class);
        messageClasses.put(GChatRequestMessage,GChatRequestMessage.class);
        messageClasses.put(GChatResponseMessage,GChatResponseMessage.class);
        messageClasses.put(GMRequestMessage,GMRequestMessage.class);
        messageClasses.put(GMResponseMessage,GMResponseMessage.class);
        messageClasses.put(PingMessage,PingMessage.class);
    }

}
